// 当前工作目录

#include <print>
#include <string>
#include <filesystem>

#ifdef WIN32
#include <Windows.h>
#elifdef LINUX
#include <unistd.h>
#endif

std::string GetCurrentExeDir();

int main(int argc, char **argv) {
  auto cur_path = GetCurrentExeDir();
  std::println("{}", cur_path);
  std::println("filesystem {}", std::filesystem::current_path().string());
  
  return 0;
}

std::string GetCurrentExeDir() {
  char szPath[1024] = {0};
#ifdef WIN32
  GetModuleFileName(NULL, szPath, 1024);
  char *p = strrchr(szPath, '\\');
#else
  readlink("/proc/self/exe", szPath, sizeof(szPath));
  char *p = strrchr(szPath, '/');
#endif
  *p = 0;
  return std::string(szPath);
}